package com.siruier.boss.ui

import android.app.Application
import androidx.lifecycle.ProcessLifecycleOwner
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.siruier.boss.ui.helper.ProcessLifecycleObserver
import com.siruier.boss.ui.utils.ActivityManger

object AppCore {
    lateinit var app: Application

    @JvmStatic
    fun init(application: Application) {
        app = application
        ActivityManger.registerActivityLifecycleCallbacks(app)
        ProcessLifecycleOwner.get().lifecycle.addObserver(ProcessLifecycleObserver)
    }

    init {
        SmartRefreshLayout.setDefaultRefreshHeaderCreator { context, layout ->
            layout.setPrimaryColorsId(R.color.white, R.color.text_color) //全局设置主题颜色
            ClassicsHeader(context)
        }
        SmartRefreshLayout.setDefaultRefreshFooterCreator { context, layout ->
            layout.setPrimaryColorsId(R.color.white, R.color.text_color) //全局设置主题颜色
            ClassicsFooter(context).setDrawableSize(20f)
        }
    }
}